#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int N = 510;
const int M = 100010;

vector<vector<int>> edges;
int n1, n2, m;
bool st[N];
int match[N];

bool find(int x)
{
    for (auto e : edges[x])
    {
        if (!st[e])
        {
            st[e] = true;
            if (match[e] == 0 || find(match[e]))
            {
                match[e] = x;
                return true;
            }
        }
    }
    return false;
}

int main()
{
    cin >> n1 >> n2 >> m;

    edges.resize(n1 + 1);

    while (m--)
    {
        int u, v; cin >> u >> v;
        edges[u].push_back(v);
    }

    int res = 0;
    for (int i = 1; i <= n1; ++i)
    {
        memset(st, false, sizeof st);
        if (find(i)) res++;
    }

    cout << res << endl;
    return 0;
}